home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / mweb / MWEB Utils / ws295sdk.exe / Ws2sdkzp.exe / SAMPLES / LAYERED / DSOCKET.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-06  |  5.8 KB  |  317 lines

  1. /*++
  2.  
  3.  
  4.      Copyright c 1996 Intel Corporation
  5.      All Rights Reserved
  6.  
  7.      Permission is granted to use, copy and distribute this software and
  8.      its documentation for any purpose and without fee, provided, that
  9.      the above copyright notice and this statement appear in all copies.
  10.      Intel makes no representations about the suitability of this
  11.      software for any purpose.  This software is provided "AS IS."
  12.  
  13.      Intel specifically disclaims all warranties, express or implied,
  14.      and all liability, including consequential and other indirect
  15.      damages, for the use of this software, including liability for
  16.      infringement of any proprietary rights, and including the
  17.      warranties of merchantability and fitness for a particular purpose.
  18.      Intel does not assume any responsibility for any errors which may
  19.      appear in this software nor any responsibility to update it.
  20.  
  21.  
  22. Module Name:
  23.  
  24. dsocket.h
  25.  
  26. Abstract:
  27.  
  28.     This  header  defines the "DSOCKET" class.  The DSOCKET class defines state
  29.     variables  and  operations for DSOCKET objects within the LSP.DLL.  A
  30.     DSOCKET  object  represents  all  of the information that the LSP.DLL knows
  31.     about a socket.
  32. --*/
  33.  
  34. #ifndef _DSOCKET_
  35. #define _DSOCKET_
  36.  
  37.  
  38. #include <winsock2.h>
  39. #include "llist.h"
  40. #include "classfwd.h"
  41.  
  42. class DSOCKET
  43. {
  44.   public:
  45.  
  46.     static
  47.     INT
  48.     DSocketClassInitialize();
  49.  
  50.     static
  51.     INT
  52.     DSocketClassCleanup();
  53.  
  54.     static 
  55.     PDSOCKET
  56.     FindDSocketFromProviderSocket (
  57.         SOCKET s
  58.         );
  59.  
  60.  
  61.     DSOCKET();
  62.  
  63.     INT
  64.     Initialize(
  65.         IN PDPROVIDER Provider,
  66.         IN SOCKET     ProviderSocket,
  67.         IN DWORD      CatalogEntryId,
  68.         IN SOCKET     Socket
  69.         );
  70.     VOID
  71.     Remove ();
  72.  
  73.     ~DSOCKET();
  74.  
  75.     SOCKET
  76.     GetProviderSocket();
  77.  
  78.     PDPROVIDER
  79.     GetDProvider();
  80.  
  81.     DWORD
  82.     GetCatalogEntryId();
  83.  
  84.     SOCKET
  85.     GetSocketHandle();
  86.  
  87.     VOID
  88.     RegisterAsyncOperation(
  89.         HWND     Window,
  90.         UINT     Message,
  91.         LONG     Events
  92.         );
  93.  
  94.     VOID
  95.     SignalAsyncEvents(
  96.         LPARAM    lParam
  97.         );
  98.  
  99.     LONG
  100.     GetAsyncEventMask();
  101.  
  102.     DWORD
  103.     GetCompletionContext ();
  104.  
  105.     VOID
  106.     SetCompletionContext (
  107.         DWORD   context
  108.         );
  109.  
  110.   private:
  111.  
  112.     PDPROVIDER  m_provider;
  113.     // Reference  to  the  DPROVIDER object representing the service provider
  114.     // that controls this socket.
  115.  
  116.     SOCKET  m_provider_socket;
  117.     // Socket handle exposed by the provider
  118.  
  119.     DWORD   m_catalog_entry_id;
  120.     // The catalog entry id of the provider that this socket is attached to.
  121.  
  122.     SOCKET  m_socket_handle;
  123.     // The socket handle returned from WPUCreateSocketHandle.
  124.  
  125.     DWORD   m_completion_context;
  126.     // Completion key if provider socket is associated with
  127.     // completion port
  128.  
  129.     LONG    m_async_events;
  130.     // The event mask for the events the client has registered interest in.
  131.  
  132.     HWND    m_async_window;
  133.     // The handle of the window to receive net event messages.
  134.  
  135.     UINT    m_async_message;
  136.     // The message to send to the client to signal net envents.
  137.  
  138.     BOOL    m_closing;
  139.     // Indicates that socket is being closed
  140.     
  141.     LIST_ENTRY  m_list_linkage;
  142.     // Provides the linkage space for a list of DSOCKET objects 
  143.  
  144.     // Note that no LIST_ENTRY is required to correspond to the DPROVIDER
  145.     // object associated  with  this  DSOCKET object since the DPROVIDER object
  146.     // does not  maintain a list of sockets it controls.
  147.     
  148.     static LIST_ENTRY m_socket_list;
  149.     // Global list of all sockets
  150.  
  151.     static CRITICAL_SECTION  m_socket_list_lock;
  152.     // Critical section that protects socket list
  153.  
  154. };   // class DSOCKET
  155.  
  156.  
  157.  
  158. inline SOCKET
  159. DSOCKET::GetSocketHandle()
  160. /*++
  161.  
  162. Routine Description:
  163.  
  164.     Retrieves  the  external socket-handle value corresponding to this internal
  165.     DSOCKET object.
  166.  
  167. Arguments:
  168.  
  169.     None
  170.  
  171. Return Value:
  172.  
  173.     The corresponding external socket-handle value.
  174. --*/
  175. {
  176.     return(m_socket_handle);
  177. }
  178.  
  179.  
  180.  
  181.  
  182. inline PDPROVIDER
  183. DSOCKET::GetDProvider()
  184. /*++
  185.  
  186. Routine Description:
  187.  
  188.     Retrieves  a reference to the DPROVIDER object associated with this DSOCKET
  189.     object.
  190.  
  191. Arguments:
  192.  
  193.     None
  194.  
  195. Return Value:
  196.  
  197.     The reference to the DPROVIDER object associated with this DSOCKET object.
  198. --*/
  199. {
  200.     return(m_provider);
  201. }
  202.  
  203.  
  204. inline DWORD
  205. DSOCKET::GetCatalogEntryId()
  206. /*++
  207.  
  208. Routine Description:
  209.  
  210.     Retrieves  a reference to the DPROVIDER object associated with this DSOCKET
  211.     object.
  212.  
  213. Arguments:
  214.  
  215.     None
  216.  
  217. Return Value:
  218.  
  219.     The reference to the DPROVIDER object associated with this DSOCKET object.
  220. --*/
  221. {
  222.     return(m_catalog_entry_id);
  223. }
  224.  
  225.  
  226. inline SOCKET
  227. DSOCKET::GetProviderSocket()
  228. /*++
  229.  
  230. Routine Description:
  231.  
  232.     Retrieves the handle for the provider socket
  233.  
  234. Arguments:
  235.  
  236.     None
  237.  
  238. Return Value:
  239.  
  240.     The provider socket associated with this socket
  241. --*/
  242. {
  243.     return(m_provider_socket);
  244. }
  245.  
  246. inline
  247. LONG
  248. DSOCKET::GetAsyncEventMask()
  249. /*++
  250.  
  251. Routine Description:
  252.  
  253.     Returns the event mask for this socket
  254.  
  255. Arguments:
  256.  
  257.     None
  258.  
  259. Return Value:
  260.  
  261.     The event mask for this socket.
  262. --*/
  263. {
  264.     return(m_async_events);
  265. }
  266.  
  267.  
  268. inline DWORD
  269. DSOCKET::GetCompletionContext()
  270. /*++
  271.  
  272. Routine Description:
  273.  
  274.     Retrieves provider's socket completion context,
  275.  
  276. Arguments:
  277.  
  278.     None
  279.  
  280. Return Value:
  281.  
  282.     Provider's socket completion context
  283.  
  284. --*/
  285. {
  286.     return(m_completion_context);
  287. }
  288.  
  289.  
  290. inline VOID
  291. DSOCKET::SetCompletionContext(
  292.     DWORD   Context
  293.     )
  294. /*++
  295.  
  296. Routine Description:
  297.  
  298.     Sets provider's socket completion context,
  299.  
  300. Arguments:
  301.  
  302.     Context     completion context
  303.  
  304. Return Value:
  305.     
  306.     None
  307.  
  308. --*/
  309. {
  310.     m_completion_context = Context;
  311. }
  312.  
  313.  
  314.  
  315.  
  316. #endif // _DSOCKET_
  317.